package com.zimin.cloud.web.controller.user;

import com.zimin.cloud.mine.pojo.user.business.UserBO;
import com.zimin.cloud.user.api.IUserFeign;
import com.zimin.shared.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;


/**
 * @author zimin
 * @since 2021/12/27 10:49 上午
 */
@RestController
@RequestMapping("/web/user")
@Slf4j
public class WebUserController {

    @Autowired
    private IUserFeign userFeign;

    @GetMapping("/users")
    public Mono<Result> userList(UserBO userBO) {
        return Mono.just(userFeign.userList(userBO));
    }

    @PostMapping
    public Mono<Result> saveUser(@RequestBody UserBO userBO) {
        return Mono.just(userFeign.saveUser(userBO));
    }

    @PutMapping
    public Mono<Result> updateUser(@RequestBody UserBO userBO) {
        return Mono.just(userFeign.updateUser(userBO));
    }

    @DeleteMapping("/{id}")
    public Mono<Result> updateUser(@PathVariable(name = "id") String userId) {
        return Mono.just(userFeign.removeUserById(userId));
    }
}
